package pers.gxm.iterator;

import java.util.Iterator;

public class BookShelfIterator implements Iterator<Book> {

    private BookShelf bookShelf;
    private int index = 0;

    public BookShelfIterator(BookShelf bookShelf){
        this.bookShelf = bookShelf;
    }

    @Override
    public boolean hasNext() {
        return index < bookShelf.getLength();
    }

    @Override
    public Book next() {
        Book book = bookShelf.getBookAt(index++);
        return book;
    }

}
